<?php
require('eRDF_parser.php');
require('PHPUnit.php');


class eRDF_TestCase extends PHPUnit_TestCase {
	
	var $eRDF;
	
	function __construct($name)
	{
		$this->PHPUnit_TestCase($name);
	}
	function setUp(){
		$this->eRDF = new eRDF_parser('erdf.test.html');
	}
	
	function tearDown(){
		unset($this->eRDF);
	}
	
	function test_check_profile()
	{
		$act = $this->eRDF->check_profile();
		$ex = true;
		$this->assertTrue($act==$ex);
	}
	
	function test_get_schemas(){
		$act = $this->eRDF->get_schemas();
		$ex = array(
					'foo'=>'http://foo.com/#',
					'owl'=>'http://www.w3.org/2002/07/owl#'
					);
		$this->assertTrue($act==$ex);
	}
	
	function test_meta_elements()
	{
		$act = $this->eRDF->meta_elements();
		$ex = array(array("s"=>'http://keithalexander.co.uk/',"p"=>'http://foo.com/#title',"o"=>"Hello"));
		$this->assertTrue($act==$ex);

	}
	
	function test_link_elements_rel()
	{
		$act = $this->eRDF->link_elements_rel();

		$ex = array(array("s"=>'http://keithalexander.co.uk/',"p"=>'http://foo.com/#likes',"o"=>"http://keithalexander.co.uk/#you"));
		$this->assertTrue($act==$ex);

	}
	
	function test_link_elements_rev()
	{
		$act = $this->eRDF->link_elements_rev();
		$ex = array(array("o"=>'http://keithalexander.co.uk/',"p"=>'http://foo.com/#likes',"s"=>"http://keithalexander.co.uk/#you"));
		$this->assertTrue($act==$ex);

	}
	
	function test_elements_with_class()
	{
		$act = $this->eRDF->elements_with_class();
		$ex = array(
				array(
					"s"=>'http://keithalexander.co.uk/#me',
					"p"=>'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
					"o"=>"http://foo.com/#Person"
					),
					array("s"=>'http://keithalexander.co.uk/#me',"p"=>'http://foo.com/#name',"o"=>"Keith A"),
					array("s"=>'http://keithalexander.co.uk/#me',"p"=>'http://foo.com/#firstName',"o"=>"Keith"),
				array("s"=>'http://keithalexander.co.uk/#me',"p"=>'http://foo.com/#img',"o"=>"http://keithalexander.co.uk/me.jpg"),
		
					);
		$this->assertTrue($act==$ex);

	}
	
	function test_anchors_with_rev()
	{
		$act = $this->eRDF->anchors_with_rev();

		$ex = array(array("s"=>'http://someone.com/#you',"p"=>'http://foo.com/#brother',"o"=>"http://keithalexander.co.uk/#me"));
		$this->assertTrue($act==$ex);

	}
	
	function test_anchors_with_rel()
	{
		$act = $this->eRDF->anchors_with_rel();
		$ex = array(
		array('s'=> 'http://keithalexander.co.uk/#me',
				'p' => 'http://www.w3.org/2002/07/owl#sameAs',
				'o' => 'http://someone.com/#you'
			),
				
					array(
							"o"=>'http://someone.com/#you',
							"p"=>'http://foo.com/#sister',
							"s"=>"http://keithalexander.co.uk/#me"
							)
		);
		$this->assertTrue($act==$ex);

	}
	
	function test_labels()
	{
		$act = $this->eRDF->labels();
			$ex = array(array("s"=>'http://someone.com/#you',"p"=>'http://www.w3.org/2000/01/rdf-schema#label',"o"=>"Link Text", "o_lang"=>'en'),
			array("s"=>'http://keithalexander.co.uk/me.jpg',"p"=>'http://www.w3.org/2000/01/rdf-schema#label',"o"=>"Image Text"),
			);
		$this->assertTrue($act==$ex);

	}
	function test_attname_to_uri()
	{
		$this->eRDF->get_schemas();
		$act = $this->eRDF->attname_to_uri('owl-sameAs');
		$ex = 'http://www.w3.org/2002/07/owl#sameAs';
		$this->assertTrue($act==$ex);
		
	}
	function test_do_owl_sameAs()
	{
		$this->eRDF->parse();
		$ex  = $this->eRDF->get_triples();		
		$act = $this->eRDF->do_owl_sameAs();
//	var_dump($ex);	
		$this->assertTrue($act!=$ex);
	}
	
}

?>
